package com.example.springboot.config.cors;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Author:ChenZhangKun
 * @Date: 2022/9/8 14:40
 */
@RestController
@CrossOrigin(origins = "*") // 解决局部跨越，表示此controller下面均接受跨域
@RequestMapping("/cors")
public class CrossOriginDemo {
    @GetMapping("/test")
    public HashMap<String, String> demo() {
        return new HashMap<String, String>() {
            {
                put("a", "a");
                put("c", "c");
            }
        };
    }
}
